package cn.yunhe.servlet;

import cn.yunhe.dao.AdressMapper;
import cn.yunhe.entity.merchantsentity.Adress;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/*
祝艳君
 */
@WebServlet("/LookAdressServlet")
public class LookAdressServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        SqlSession sqlSession= SqlSessionFactoryUtil.getSqlSession();
        AdressMapper adressMapper=sqlSession.getMapper(AdressMapper.class);
        int mid=Integer.parseInt(request.getParameter("mid"));
        //根据商家id返回实体类
        Adress adress=adressMapper.getAddressById(mid);
        request.setAttribute("adress",adress);
        request.getRequestDispatcher("bai.jsp").forward(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
